$(document).ready(function(){
	$('#menu').on('click','li',function(){
		if ($(this).hasClass('current')) {
			return;
		}else{
			$(this).addClass('current').siblings('li').removeClass('current');
		};
         
	});
	$('#button').on('mouseenter',function(){
	   $(this).css('background-position','0 -356px');
	   $(this).find('iframe').attr({height:80,width:354});
	   $($(this).find('iframe')[0].contentWindow.document).find('#launchBtn').css({
	        width:354,
	   		height:80
	   });
	});
	$('#button').on('mouseout',function(){$(this).css('background-position','0 -275px');});
});


function bannerAnimate(intervalTime,runTime){  
	var imgList=$('#slider>li');
	var len=imgList.length;
	var iconImg=$('#banner_circle>span');
	var nowImg=0;
	//自动翻转
	var timer=setInterval(turnNextImg,intervalTime);
	var banner_turn=$('.banner-arrow');
	//鼠标悬停在banner区域时停止自动翻
	$('#banner_show').hover(function(){clearInterval(timer);banner_turn.show();},function(){timer=setInterval(turnNextImg,intervalTime);banner_turn.hide();});
	//向下一张翻转
	function turnNextImg(){
		if(!imgList.is(':animated')){
			imgList.eq(nowImg).animate({opacity:0,zIndex:1},runTime);
			if(nowImg<len-1){
				nowImg++;  	    
			}else{
				nowImg=0;
			}
			imgList.eq(nowImg).animate({opacity:1,zIndex:2},runTime);
			iconImg.eq(nowImg).addClass('cur').siblings().removeClass('cur');
		}
	}
	//向上一张翻转
	function turnPrevImg(){
		if(!imgList.is(':animated')){
			imgList.eq(nowImg).animate({opacity:0,zIndex:1},runTime);
			if(nowImg>0){
			    nowImg--;
			}else{
			    nowImg=len-1;
			}
			imgList.eq(nowImg).animate({opacity:1,zIndex:2},runTime);
			iconImg.eq(nowImg).addClass('cur').siblings().removeClass('cur');
		}
	}
	//下一张按钮翻转
	$('#banner_pre').click(function(){
		turnNextImg();
	});
	//上一张按钮翻转
	$('#banner_next').click(function(){
		turnPrevImg();
	});
    //小图标按钮翻转
	iconImg.click(function(){
		if(!imgList.is(':animated')){
			imgList.eq(nowImg).animate({opacity:0,zIndex:1},runTime);
			nowImg=$(this).index();
			imgList.eq(nowImg).animate({opacity:1,zIndex:2},runTime);
			$(this).addClass('cur').siblings().removeClass('cur');
		}
	});
}
//自动推送工具代码
(function(){
  var bp = document.createElement('script');
  bp.src = '//push.zhanzhang.baidu.com/push.js';
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(bp, s);
})();

//购买截止日
function validTime(d){
	var dateObj = new Date();
	var year = dateObj.getFullYear();
	var month = dateObj.getMonth()+1;
	var day = dateObj.getDate();
	var mText = $('#month');
	var dText = $('#day');
	var promptTxt = $('#prompt');
	var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	if (year < 2000) year += 1900; // Y2K fix
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monarr[1] = "29";// 计算闰年
	if(day == d){
		promptTxt.html('<em id="month">'+month+'</em>月社保缴费截止时间：<em>今天</em>')
	}else if(day < d){
		mText.text(month);
		dText.text(d-day);
		return false;
	}else{
		month > 12 ? month=1:month = month+1;
		mText.text(month);
		dText.text(monarr[month-1]-day+d);
		return false;
	}
}